import 'package:flutter/material.dart';
import 'package:live_music/models/moment_detail_model.dart';
import 'package:live_music/pages/video/widget/constants.dart';
import 'package:live_music/utils/contentParse.dart';
import 'package:live_music/utils/util.dart';
import 'package:marquee/marquee.dart';

class VideoBottomBarWidget extends StatefulWidget {
  final MomentDetailModel videoItem;
  VideoBottomBarWidget({
    Key key,
    this.videoItem,
  }) : super(key: key);

  @override
  _VideoBottomBarWidgetState createState() {
    return _VideoBottomBarWidgetState();
  }
}

class _VideoBottomBarWidgetState extends State<VideoBottomBarWidget> {
  @override
  Widget build(BuildContext context) {
    double maxWidth =
        MediaQuery.of(context).size.width - kVinylDiskContainerWidth;
    return ConstrainedBox(
      constraints: BoxConstraints(
        maxWidth: maxWidth,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              Text(
                '@' + widget.videoItem.userName,
                style: _getTextStyle(),
              ),
              SizedBox(
                width: 6,
              ),
              Container(
                alignment: Alignment.bottomLeft,
                child: Text(
                  getDateTime(widget.videoItem.createTime),
                  style: TextStyle(
                    fontSize: 12,
                    color: Colors.grey,
                  ),
                ),
              )
            ],
          ),
          SizedBox(
            height: 8,
          ),
          Text(
            widget.videoItem.video.title,
            style: _getTextStyle(),
          ),
          SizedBox(
            height: 5,
          ),
          FormattedText(
            widget.videoItem.textContent,
            style: TextStyle(
              fontSize: 12,
              color: Colors.grey[200],
            ),
            maxLines: 5,
            overflow: TextOverflow.ellipsis,
          ),
          SizedBox(
            height: 10,
          ),
          Row(
            children: [
              Image.asset(
                'assets/images/common/music.png',
                width: 25,
                height: 25,
              ),
              Container(
                width: 200,
                height: 25,
                child: Marquee(
                  text: '用户创作的原生--' + widget.videoItem.userName,
                  style: TextStyle(fontSize: 15, color: Colors.white),
                ),
              )
            ],
          ),
        ],
      ),
    );
  }

  _getTextStyle() {
    return TextStyle(
      color: Colors.white,
    );
  }
}
